import { storeToRefs } from 'pinia';
import { useCounterStore } from '../stores/counter.ts';

export function useCounter() {
  const counterStore = useCounterStore();

  // 使用 storeToRefs 获取响应式属性
  const { count, arr, doubleCount, arrSum } = storeToRefs(counterStore);
  // 返回 store 中的方法
  const increment = counterStore.increment;
  const updateArr = counterStore.updateArr;

  return {
    count,
    arr,
    doubleCount,
    arrSum,
    increment,
    updateArr,
  };
}
